package com.zhenmaitang.clinic_sys.mapper;

import com.zhenmaitang.clinic_sys.entity.SysMenu;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface SysMenuMapper {
    
    List<SysMenu> findAll();
    
    SysMenu findById(@Param("id") Integer id);

    SysMenu findByPermissionCode(@Param("permissionCode") String permissionCode);

    List<SysMenu> findMenusByUserId(@Param("userId") Integer userId);

    List<SysMenu> findMenusByRoleName(@Param("roleName") String roleName);

    List<SysMenu> findChildrenByParentId(@Param("parentId") Integer parentId);

    List<SysMenu> findParentMenus();

    List<Integer> findMenuIdsByRoleId(@Param("roleId") Integer roleId);

    boolean existsByPermissionCode(@Param("permissionCode") String permissionCode);

    int insert(SysMenu menu);

    int update(SysMenu menu);

    int deleteById(@Param("id") Integer id);

    void deleteMenusByRoleId(@Param("roleId") Integer roleId);

    void assignMenuToRole(@Param("roleId") Integer roleId, @Param("menuId") Integer menuId);
}